{

SwiftForth wrapper

}

\ Open/Save dialogs

ofn-dialogs open-package

public

0  OFN_LONGNAMES or
   OFN_HIDEREADONLY or
constant seki-open-flags

ofn-dialog subclass image-dialog
   create image-files
      ,z" Image files (*.png;*.bmp;*.jpg;*.gif;*.pcx;*.tif;*.psd;*.ico)"            ,z" *.png;*.bmp;*.jpg;*.gif;*.pcx;*.tif;*.psd;*.ico"
      ,z" All files (*.*)"        ,z" *.*"
      0 ,
   : custom ( -- title filter flags )
      seki-window Owner !
      z" Open file"  image-files seki-open-flags ;
end-class

create unknown-file 256 /allot

ofn-dialog subclass specific-dialog
   : custom ( -- title filter flags )
      seki-window Owner !
      z" Open File"  unknown-file seki-open-flags ;
end-class

: ofn-all  ( -- filename count true | false )
   [objects   ofn-dialog makes ofn   objects]
   ofn choose dup if ofn filename zcount rot then ;

: ofn-image   ( -- filename count true | false )
   [objects   image-dialog makes ofn   objects]
   ofn choose dup if ofn filename zcount rot then ;

: ofn-specific ( string count pattern-string count -- filename count true | false )
   [objects   ofn-dialog makes ofn   objects]
   unknown-file 256 erase
   2swap unknown-file zplace
   unknown-file zcount + zplace
   ofn choose dup if ofn filename zcount rot then ;


sfn-dialog subclass save-image-dialog
   create image-save-files
      ,z" Portable Network Graphics (.PNG)"            ,z" *.png"
      ,z" All files (*.*)"                             ,z" *.*"
      0 ,
   : custom ( -- title filter flags )
      seki-window Owner !
      z" Save Image"  image-save-files DEFAULT-SAVE-FLAGS ;
end-class


: sfn-any
   [objects   sfn-dialog makes sfn   objects]
   sfn choose dup if sfn filename zcount rot then ;

: sfn-image
   [objects   save-image-dialog makes sfn   objects]
   sfn choose dup if sfn +ext sfn filename zcount rot then ;

end-package



: BUFFER: create /allot ;

\ : ?exit  ;
